package main

import (
	service "github.com/longjoy/micro-go-course/section16/service"
	"log"
	"net"
	"net/http"
	"net/rpc"
)

// 16 | Go RPC 如何实现服务间通信？
// https://kaiwu.lagou.com/course/courseInfo.htm?courseId=287#/detail/pc?id=3814
// 实现 RPC 服务器
func main() {
	stringService := new(service.StringService)
	// 注册服务
	rpc.Register(stringService)
	rpc.HandleHTTP()
	// 监听对应 socket 并对外提供服务
	l, e := net.Listen("tcp", "127.0.0.1:1234")
	if e != nil {
		log.Fatal("listen error:", e)
	}
	http.Serve(l, nil)
}
